package my.provider.demo.controller;

import my.provider.demo.service.ServiceDefault;
import my.provider.demo.vo.JDBCVo;
import my.provider.demo.vo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("userdefault")
public class UserDefaultController {

    @Autowired
    private ServiceDefault service;
    @Autowired
    private JDBCVo jdbcVo;

    @PostMapping("addUser")
    public String addUser(@RequestBody User user) {
        return service.addUser(user);
    }

    @PostMapping("updateUser")
    public boolean updateUser(@RequestBody User user) {
        return service.updateUser(user);
    }

    @GetMapping("getUser")
    public User getUser(@RequestParam String userId) {
        System.out.println("getuser!!");
        return service.getUser(userId);
    }

    @PostMapping("removeUser")
    public boolean removeUser(@RequestParam String userId) {
        return service.removeUser(userId);
    }

    @GetMapping("getConfig")
    public String getConfig(){
        System.out.println("y");
        return jdbcVo.toString();
    }
}
